const router = require('koa-router')()
const mysql = require('mysql');
const { query } = require('../public/javascripts/db');

router.prefix('/behind');

router.get('/', async (ctx, next) => {
    await ctx.render('behind')
})

router.get('/user', async (ctx, next) => {
    let option = { List: [] };
    let sql = 'select * from user';
    await query(sql, []).then(res => {
        option.List = res
    });
    ctx.body = option;
})

router.get('/review', async (ctx, next) => {
    let option = { List: [] };
    let sql = 'select * from review';
    await query(sql, []).then(res => {
        option.List = res
    });
    ctx.body = option;
})

router.get('/reviewdc', async (ctx, next) => {
    let option = { List: [] };
    let sql = 'select * from reviewdc';
    await query(sql, []).then(res => {
        option.List = res
    });
    ctx.body = option;
})

router.get('/sgroup', async (ctx, next) => {
    let option = { List: [] };
    let sql = 'select * from sgroup';
    await query(sql, []).then(res => {
        option.List = res
    });
    ctx.body = option;
})

router.get('/target', async (ctx, next) => {
    let sql = 'select * from target';
    let option = { List: [] };
    await query(sql, []).then(res => {
        option.List = res
    });
    ctx.body = option;
})

module.exports = router